// function fn() {
//     let dv = document.querySelector('.menu');

//     fetch("http://chst.vip:1234/api/getindexmenu")
//         .then(body => body.json())
//         .then(res => {
//             render(res.result, dv)
//         });

//     function render(data, el) {
//         data.forEach(item => {
//             let li = document.createElement('li');
//             let domStr = `
//              ${item.img}
//              <p>${item.name}</p>
//              `
//             li.innerHTML = domStr;

//             el.appendChild(li)
//         })
//     }
// }
// fn()

let info = document.querySelector('.info')

fetch("http://chst.vip:1234/api/getmoneyctrl")
    .then(body => body.json())
    .then(res => {
        render(res.result, info)
    })

function render(data, el) {
    let domStr = "";
    data.forEach(item => {
        let regExp = /(?<=imgurl=)[^'"]*/
        let result = item.productImg2.match(regExp)
        domStr += `<li productid=${item.productId}>
        <img width="100" src="${result[0]}" alt="">
        <h3>${item.productName}<span>${item.productPinkage}</span></h3>
        <span>${item.productComCount}</span>
        <span>${item.productFrom}</span>
        </li>  `
        el.innerHTML = domStr;

    })
}



let uu = document.querySelector('.info')
uu.onclick = function(e) {
    if (e.target.localName === 'li') {
        let _this = e.target;
        let id = _this.getAttribute('productid')
        location.href = '../html/detail.html?productid=' + id
    }
}




$("ul li").eq(0).click(function() {
    location.href = "./search.html"
})
$("ul li").eq(1).click(function() {
    location.href = "./save.html"
})
$("ul li").eq(2).click(function() {
    location.href = "./inlanddiscount.html"
})
$("ul li").eq(3).click(function() {
    location.href = "./baicaijia.html"
})
$("ul li").eq(4).click(function() {
    location.href = "./save.html"
})
$("ul li").eq(5).click(function() {
    location.href = "./6.html"
})
$("ul li").eq(6).click(function() {
    location.href = "./search.html"
})
$("ul li").eq(8).click(function() {
    location.href = "./8.html"
})
$("ul li").eq(9).click(function() {
    location.href = "./search.html"
})
$("ul li").eq(10).click(function() {
    location.href = "./sitenav.html"
})
$("ul li").eq(11).click(function() {
    location.href = "./11.html"
})
$(".mab").click(function() {
    $(".active").slideToggle(200)
})